package com.agile.leetcode.designmodel.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author KD
 * @Date 2021/1/11 15:47
 */
public class ConcreateSubject implements Subject {
    List<Observer> list = new ArrayList<>(10);

    @Override
    public void attach(Observer observer) {
        list.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        list.remove(observer);
    }

    @Override
    public void notify(String message) {
        for (Observer observer : list) {
            observer.update(message);
        }
    }
}
